<?php


namespace app\common\model;


class AuthRule extends BaseModel
{
    public function __construct(array $data = [])
    {
        parent::__construct($data);
    }

    public function searchTitleAttr($query, $value, $data)
    {
        $query->where('title', 'like', '%'.$value.'%');
    }

    public function searchUrlAttr($query, $value, $data)
    {
        $query->where('url', '=', $value);
    }
    
    // 获取所有下有部门
    public static function getAllSonIdsList($id)
    {
        $ids = [];
        $ids[] = $id;
        $list = AuthRule::where('pid',$id)->select();
        foreach ($list as $item) {
            $new = self::getAllSonIdsList($item['id']);
            $ids = array_merge($ids,$new);
        }
        return $ids;
    }
}